Optimal. Leaf size=65 \[ -b^2 \cos (2 a) \text {Ci}\left (\frac {2 b}{x}\right )+\frac {1}{2} x^2 \sin ^2\left (a+\frac {b}{x}\right )+\frac {1}{2} b x \sin \left (2 \left (a+\frac {b}{x}\right )\right )+b^2 \sin (2 a) \text {Si}\left (\frac {2 b}{x}\right ) \]
[Out]
________________________________________________________________________________________
Rubi [A]
time = 0.07, antiderivative size = 65, normalized size of antiderivative = 1.00, number of steps
used = 8, number of rules used = 8, integrand size = 12, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.667, Rules used = {3474, 4669,
3454, 3442, 3378, 3384, 3380, 3383} \begin {gather*} b^2 (-\cos (2 a)) \text {CosIntegral}\left (\frac {2 b}{x}\right )+b^2 \sin (2 a) \text {Si}\left (\frac {2 b}{x}\right )+\frac {1}{2} x^2 \sin ^2\left (a+\frac {b}{x}\right )+\frac {1}{2} b x \sin \left (2 \left (a+\frac {b}{x}\right )\right ) \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
Rule 3378
Rule 3380
Rule 3383
Rule 3384
Rule 3442
Rule 3454
Rule 3474
Rule 4669
Rubi steps
\begin {align*} \int x \sin ^2\left (a+\frac {b}{x}\right ) \, dx &=\frac {1}{2} x^2 \sin ^2\left (a+\frac {b}{x}\right )+b \int \cos \left (a+\frac {b}{x}\right ) \sin \left (a+\frac {b}{x}\right ) \, dx\\ &=\frac {1}{2} x^2 \sin ^2\left (a+\frac {b}{x}\right )+\frac {1}{2} b \int \sin \left (2 \left (a+\frac {b}{x}\right )\right ) \, dx\\ &=\frac {1}{2} x^2 \sin ^2\left (a+\frac {b}{x}\right )+\frac {1}{2} b \int \sin \left (2 a+\frac {2 b}{x}\right ) \, dx\\ &=\frac {1}{2} x^2 \sin ^2\left (a+\frac {b}{x}\right )-\frac {1}{2} b \text {Subst}\left (\int \frac {\sin (2 a+2 b x)}{x^2} \, dx,x,\frac {1}{x}\right )\\ &=\frac {1}{2} x^2 \sin ^2\left (a+\frac {b}{x}\right )+\frac {1}{2} b x \sin \left (2 \left (a+\frac {b}{x}\right )\right )-b^2 \text {Subst}\left (\int \frac {\cos (2 a+2 b x)}{x} \, dx,x,\frac {1}{x}\right )\\ &=\frac {1}{2} x^2 \sin ^2\left (a+\frac {b}{x}\right )+\frac {1}{2} b x \sin \left (2 \left (a+\frac {b}{x}\right )\right )-\left (b^2 \cos (2 a)\right ) \text {Subst}\left (\int \frac {\cos (2 b x)}{x} \, dx,x,\frac {1}{x}\right )+\left (b^2 \sin (2 a)\right ) \text {Subst}\left (\int \frac {\sin (2 b x)}{x} \, dx,x,\frac {1}{x}\right )\\ &=-b^2 \cos (2 a) \text {Ci}\left (\frac {2 b}{x}\right )+\frac {1}{2} x^2 \sin ^2\left (a+\frac {b}{x}\right )+\frac {1}{2} b x \sin \left (2 \left (a+\frac {b}{x}\right )\right )+b^2 \sin (2 a) \text {Si}\left (\frac {2 b}{x}\right )\\ \end {align*}
________________________________________________________________________________________
Mathematica [A]
time = 0.12, size = 65, normalized size = 1.00 \begin {gather*} -b^2 \cos (2 a) \text {Ci}\left (\frac {2 b}{x}\right )+\frac {1}{4} x \left (x-x \cos \left (2 \left (a+\frac {b}{x}\right )\right )+2 b \sin \left (2 \left (a+\frac {b}{x}\right )\right )\right )+b^2 \sin (2 a) \text {Si}\left (\frac {2 b}{x}\right ) \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
Maple [A]
time = 0.08, size = 76, normalized size = 1.17
method | result | size |
derivativedivides | \(-b^{2} \left (-\frac {x^{2}}{4 b^{2}}+\frac {\cos \left (2 a +\frac {2 b}{x}\right ) x^{2}}{4 b^{2}}-\frac {\sin \left (2 a +\frac {2 b}{x}\right ) x}{2 b}-\sinIntegral \left (\frac {2 b}{x}\right ) \sin \left (2 a \right )+\cosineIntegral \left (\frac {2 b}{x}\right ) \cos \left (2 a \right )\right )\) | \(76\) |
default | \(-b^{2} \left (-\frac {x^{2}}{4 b^{2}}+\frac {\cos \left (2 a +\frac {2 b}{x}\right ) x^{2}}{4 b^{2}}-\frac {\sin \left (2 a +\frac {2 b}{x}\right ) x}{2 b}-\sinIntegral \left (\frac {2 b}{x}\right ) \sin \left (2 a \right )+\cosineIntegral \left (\frac {2 b}{x}\right ) \cos \left (2 a \right )\right )\) | \(76\) |
risch | \(-\frac {i \pi \,\mathrm {csgn}\left (\frac {b}{x}\right ) {\mathrm e}^{-2 i a} b^{2}}{2}+i \sinIntegral \left (\frac {2 b}{x}\right ) {\mathrm e}^{-2 i a} b^{2}+\frac {\expIntegral \left (1, -\frac {2 i b}{x}\right ) {\mathrm e}^{-2 i a} b^{2}}{2}+\frac {b^{2} \expIntegral \left (1, -\frac {2 i b}{x}\right ) {\mathrm e}^{2 i a}}{2}+\frac {x^{2}}{4}-\frac {x^{2} \cos \left (\frac {2 a x +2 b}{x}\right )}{4}+\frac {b x \sin \left (\frac {2 a x +2 b}{x}\right )}{2}\) | \(112\) |
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [C] Result contains complex when optimal does not.
time = 0.35, size = 87, normalized size = 1.34 \begin {gather*} -\frac {1}{2} \, {\left ({\left ({\rm Ei}\left (\frac {2 i \, b}{x}\right ) + {\rm Ei}\left (-\frac {2 i \, b}{x}\right )\right )} \cos \left (2 \, a\right ) + {\left (i \, {\rm Ei}\left (\frac {2 i \, b}{x}\right ) - i \, {\rm Ei}\left (-\frac {2 i \, b}{x}\right )\right )} \sin \left (2 \, a\right )\right )} b^{2} - \frac {1}{4} \, x^{2} \cos \left (\frac {2 \, {\left (a x + b\right )}}{x}\right ) + \frac {1}{2} \, b x \sin \left (\frac {2 \, {\left (a x + b\right )}}{x}\right ) + \frac {1}{4} \, x^{2} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [A]
time = 0.35, size = 90, normalized size = 1.38 \begin {gather*} -\frac {1}{2} \, x^{2} \cos \left (\frac {a x + b}{x}\right )^{2} + b x \cos \left (\frac {a x + b}{x}\right ) \sin \left (\frac {a x + b}{x}\right ) + b^{2} \sin \left (2 \, a\right ) \operatorname {Si}\left (\frac {2 \, b}{x}\right ) + \frac {1}{2} \, x^{2} - \frac {1}{2} \, {\left (b^{2} \operatorname {Ci}\left (\frac {2 \, b}{x}\right ) + b^{2} \operatorname {Ci}\left (-\frac {2 \, b}{x}\right )\right )} \cos \left (2 \, a\right ) \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \int x \sin ^{2}{\left (a + \frac {b}{x} \right )}\, dx \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [B] Leaf count of result is larger than twice the leaf count of optimal. 283 vs.
\(2 (62) = 124\).
time = 4.92, size = 283, normalized size = 4.35 \begin {gather*} -\frac {4 \, a^{2} b^{3} \cos \left (2 \, a\right ) \operatorname {Ci}\left (-2 \, a + \frac {2 \, {\left (a x + b\right )}}{x}\right ) + 4 \, a^{2} b^{3} \sin \left (2 \, a\right ) \operatorname {Si}\left (2 \, a - \frac {2 \, {\left (a x + b\right )}}{x}\right ) - \frac {8 \, {\left (a x + b\right )} a b^{3} \cos \left (2 \, a\right ) \operatorname {Ci}\left (-2 \, a + \frac {2 \, {\left (a x + b\right )}}{x}\right )}{x} - \frac {8 \, {\left (a x + b\right )} a b^{3} \sin \left (2 \, a\right ) \operatorname {Si}\left (2 \, a - \frac {2 \, {\left (a x + b\right )}}{x}\right )}{x} + \frac {4 \, {\left (a x + b\right )}^{2} b^{3} \cos \left (2 \, a\right ) \operatorname {Ci}\left (-2 \, a + \frac {2 \, {\left (a x + b\right )}}{x}\right )}{x^{2}} + 2 \, a b^{3} \sin \left (\frac {2 \, {\left (a x + b\right )}}{x}\right ) + \frac {4 \, {\left (a x + b\right )}^{2} b^{3} \sin \left (2 \, a\right ) \operatorname {Si}\left (2 \, a - \frac {2 \, {\left (a x + b\right )}}{x}\right )}{x^{2}} + b^{3} \cos \left (\frac {2 \, {\left (a x + b\right )}}{x}\right ) - \frac {2 \, {\left (a x + b\right )} b^{3} \sin \left (\frac {2 \, {\left (a x + b\right )}}{x}\right )}{x} - b^{3}}{4 \, {\left (a^{2} - \frac {2 \, {\left (a x + b\right )} a}{x} + \frac {{\left (a x + b\right )}^{2}}{x^{2}}\right )} b} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Mupad [F]
time = 0.00, size = -1, normalized size = -0.02 \begin {gather*} \int x\,{\sin \left (a+\frac {b}{x}\right )}^2 \,d x \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________